$(function() {
    var grid = $('#gridCountBusiness').datagrid({
		//title: "按开票单位汇总",
        //iconCls: 'icon-save',
        methord: 'post',
        //url: '/Main/CountBillByUnit',
        striped: true, //奇偶行是否区分
        columns: [[
					{ field: 'UnitName', title: '单位名称', rowspan:2 },
                    { title: '股权转让', colspan: 2},
                    { title: '注销', colspan: 2},
					{ title: '两税核实', colspan: 2},
					{ title: '资格认定', colspan: 2},
					{ title: '减免税', colspan: 2},
					{ title: '税前扣除', colspan: 2},
					{ title: '弥补亏损', colspan: 2},
					{ title: '房产评估', colspan: 2},
					{ title: '小型微利', colspan: 2},
					{ title: '土地增值税', colspan: 2},
					{ title: '企业内审', colspan: 2},
					{ title: '临时汇缴', colspan: 2},
					{ title: '其他单项', colspan: 2},
					{ title: '综合代理', colspan: 2},
					{ title: '代理记账', colspan: 2},
					{ title: '代开发票', colspan: 2},
					{ title: '汇算清缴', colspan: 2},
					{ title: '工程审计', colspan: 2},
					{ title: '房地产咨询', colspan: 2},
					{ title: '协作培训', colspan: 2},
					{ title: '注会业务', colspan: 2},
					{ title: '其他业务', colspan: 2}
				],[
				    { field: 'tp11', title: '元', width:80 },
                    { field: 'ctp11', title: '笔'},
					{ field: 'tp12', title: '元', width:80 },
                    { field: 'ctp12', title: '笔'},
					{ field: 'tp13', title: '元', width:80 },
                    { field: 'ctp13', title: '笔'},
					{ field: 'tp14', title: '元', width:80 },
                    { field: 'ctp14', title: '笔'},
					{ field: 'tp15', title: '元', width:80 },
                    { field: 'ctp15', title: '笔'},
					{ field: 'tp16', title: '元', width:80 },
                    { field: 'ctp16', title: '笔'},
					{ field: 'tp17', title: '元', width:80 },
                    { field: 'ctp17', title: '笔'},
					{ field: 'tp18', title: '元', width:80 },
                    { field: 'ctp18', title: '笔'},
					{ field: 'tp19', title: '元', width:80 },
                    { field: 'ctp19', title: '笔'},
					{ field: 'tp20', title: '元', width:80 },
                    { field: 'ctp20', title: '笔'},
					{ field: 'tp21', title: '元', width:80 },
                    { field: 'ctp21', title: '笔'},
					{ field: 'tp22', title: '元', width:80 },
                    { field: 'ctp22', title: '笔'},
					{ field: 'tp23', title: '元', width:80 },
                    { field: 'ctp23', title: '笔'},
					{ field: 'tp2', title: '元', width:80 },
                    { field: 'ctp2', title: '笔'},
					{ field: 'tp3', title: '元', width:80 },
                    { field: 'ctp3', title: '笔'},
					{ field: 'tp4', title: '元', width:80 },
                    { field: 'ctp4', title: '笔'},
					{ field: 'tp5', title: '元', width:80 },
                    { field: 'ctp5', title: '笔'},
					{ field: 'tp6', title: '元', width:80 },
                    { field: 'ctp6', title: '笔'},
					{ field: 'tp7', title: '元', width:80 },
                    { field: 'ctp7', title: '笔'},
					{ field: 'tp8', title: '元', width:80 },
                    { field: 'ctp8', title: '笔'},
					{ field: 'tp9', title: '元', width:80 },
                    { field: 'ctp9', title: '笔'},
					{ field: 'tp10', title: '元', width:80 },
                    { field: 'ctp10', title: '笔'}
				  ]
				],

        rownumbers: true,
        fitColumns: true,
		onLoadError: function(data, status, error){
			if(data.status == "400")
				indexPage.reLogin();
		}
    });
});

var CountBusiness = {};

CountBusiness.DoCount = function(){
	var date1 = $("#CountDate1").datebox('getValue');
	var date2 = $("#CountDate2").datebox('getValue');
	var ctype = $("#CountType").combobox('getValue');
	if(ctype=="")
	{
		$.messager.alert('提示','请选择汇总类型','info');
		return false;
	}
	
	if(date1=="" || date2=="")
	{
		$.messager.alert('提示','请选择起止日期','info');
		return false;
	}
		
	$("#gridCountBusiness").datagrid({ url: '/Main/GetCount', queryParams: { date1: date1, date2: date2, ctype:ctype } });
}

CountBusiness.ExportToExcel = function(){
	var rows = $("#gridCountBusiness").datagrid("getRows");
	var bodyData = JSON.stringify(rows);  //转成json字符串
    var url = "/main/CountExportToExcel";
	$("<form method='post' action='" + url + "'><input name='data' type='text' value='"+ bodyData +"' /></form>").appendTo("body").submit().remove();

}